<?php
/**
 * polwebgis
 * 
 * This file is part of polwebgis.
 *
 * @copyright   Copyright (c) 2012 Dominik Janisch (http://www.joanneum.at)
 * @lastmodified    $LastChangedDate: 2012-03-07 09:15:12 +0000 (Wed, 07 Mar 2012) $
 * @revision    $Revision: 160 $ 
 */

//require_once("IDS/Init.php");
class Request
{
    
    private static $class_instance_;
    private static $instance_ = false;
    private $arr_request_ = array("cookie", "files", "get", "post", "server");
    private $ids_result_ = 0;
        
    protected function __construct()
    {
        //$this->runIdsCheck();
        $this->arr_request_['cookie'] =  $_COOKIE;
        $this->arr_request_['files'] =  $_FILES;
        $this->arr_request_['get'] =  $_GET;
        $this->arr_request_['post'] =  $_POST;
        $this->arr_request_['server'] = $_SERVER;
        unset($_FILES);
        unset($_GET);
        unset($_POST);
        unset($_SERVER);
    }
        
    public function __destruct(){}
    
    private function __clone(){}
    
    public static function getInstance()
    {
        if(!self::$instance_)
        {
            self::$class_instance_ = new Request();
            self::$instance_ = true;
            return self::$class_instance_;
        }
        return self::$class_instance_;
    }
    
    /**
    * @return: (bool)
    * 
    * @param: (string) array_name
    * 
    * @param: (string) param_name
    */    
    public function issetParameter($array_name, $param_name)
    {
        return isset($this->arr_request_[$array_name][$param_name]);
    }
    
    /**
     * @return: parameter
     * 
     * @param: (string) array_name
     * 
     * @param: (string) param_name
     */    
    public function getParameter($array_name, $param_name)
    {
        if(isset($this->arr_request_[$array_name][$param_name]))
            return $this->arr_request_[$array_name][$param_name];
        return null;
    }
    
    /**
    * @return: (array)
    * 
    * @param: (string) array_name
    */
    public function getArray($array_name)
    {
        if(isset($this->arr_request_[$array_name]))
            return $this->arr_request_[$array_name];
        return array();
    }
    
    /*public function getImpactNumber()
    {
        return $this->ids_result_;
    }
    
    private function runIdsCheck()
    {
        $path_to_ids = PATH_TO_ADMIN_CP."/components/phpids/";
        $request = array('GET' => $_GET, 'POST' => $_POST, 'COOKIE' => $_COOKIE);
        $init = IDS_Init::init($path_to_ids . 'IDS/Config/Config.ini');
        $ids = new IDS_Monitor($request, $init);
        $result = $ids->run();
        if(($this->ids_result_ = $result->getImpact()) > 0)
        {
            $debug_message = $_SERVER['REMOTE_ADDR'] . ";" . date("Y.m.d - H:i") . ";";
            $debug_message .= $result;
            $debug_message .= "\n-----------------------\n";
            $debugger = DebuggerLog::getInstance(AP_NAME . '_impact.log');
            $debugger->debug($debug_message);
        }
    }*/
}

?>
